package com.ptszyxx.popose.module.main.ticket;

import android.os.Bundle;
import android.view.KeyEvent;

import androidx.lifecycle.ViewModelProviders;

import com.ptszyxx.popose.BR;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.databinding.ActivityRealDialogBinding;
import com.ptszyxx.popose.module.main.ticket.vm.RealDialogVM;
import com.ysg.base.BaseActivity;
import com.ysg.http.data.AppViewModelFactory;

public class RealDialogActivity extends BaseActivity<ActivityRealDialogBinding, RealDialogVM> {
    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_real_dialog;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public RealDialogVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(RealDialogVM.class);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (viewModel.isJumped){
            viewModel.requestUser();
        }
    }

    @Override
    public void initView() {
        super.initView();
        setFinishOnTouchOutside(false);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode==KeyEvent.KEYCODE_BACK){
            return false;
        }
        return super.onKeyDown(keyCode, event);
    }
}
